package com.project.fiveCerealsSavoury.service;
import java.io.UnsupportedEncodingException;
import java.sql.Timestamp;
import java.util.List;

import com.project.fiveCerealsSavoury.domain.Order;
import com.project.fiveCerealsSavoury.domain.OrderState;
import com.project.fiveCerealsSavoury.exception.BizException;
import com.project.fiveCerealsSavoury.transfer.AddOrder;
import com.project.fiveCerealsSavoury.transfer.Page;
import com.project.fiveCerealsSavoury.transfer.UserPage;

public interface OrderService {
	/**
	 * 生成订单
	 * @param order
	 * @return
	 */
	public boolean addOrder(Order order) throws BizException;
	
	/**
	 * 查询指定状态的订单
	 * @param userId
	 * @param orderstate
	 * @return
	 */
	public List<Order> queryStateOrder(Integer userId, OrderState orderstate) throws BizException;
	
	/**
	 * 修改订单状态
	 * @param orderNumber
	 * @param orderState
	 * @return
	 */
	public boolean modifyOrderState(String orderNumber, OrderState orderState) throws BizException;
	
	/**
	 * 删除订单
	 * @param orderNumber
	 * @param orderState
	 * @return
	 */
	public boolean removeOrder(String orderNumber, OrderState orderState) throws BizException;
	
	/**
	 * 分页查询所有订单
	 * @param userPage
	 * @return
	 */
	public Page queryList(UserPage userPage,OrderState orderState);
	
	/**
	 * 根据id 状态 查询
	 * @param id
	 * @param orderState
	 * @return
	 */
	public Order queryById(Integer id, OrderState orderState) throws BizException;

	
	/**
	 * 根据订单状态查询所有人的订单信息
	 * @param orderState
	 * @return
	 * @throws BizException
	 */
	public List<Order> queryOrder(OrderState orderState) throws BizException;
	/**
	 * 查询所有已支付订单数量
	 * @return
	 */
	public int counts();
	
	/**
	 * 添加到购物车
	 * @param order
	 */
	public Integer addToCar(AddOrder addOrder);
	

	/**
	 * 根据商品名称和状态查询订单
	 * @param goodName
	 * @param orderState
	 * @return
	 * @throws UnsupportedEncodingException 
	 */
	public Order queryCar(Integer userId,String goodName,OrderState orderState) throws BizException, UnsupportedEncodingException;
	
	/**
	 * 根据订单id修改商品数量
	 * @param id
	 * @return
	 */
	public boolean modifyNumber(Integer id,Integer newNumber) throws BizException;
	
	/**
	 * 根据订单id和订单状态删除购物车的商品
	 * @param id
	 * @param orderState
	 * @return
	 */
	public boolean removeCar(Integer id,OrderState orderState) throws BizException;
	
	/**
	 * 根据订单编号查询id
	 * @param orderNumber
	 * @return
	 * @throws BizException
	 */
	public Order queryByOrderState(String orderNumber) throws BizException;
	
	/**
	 * 修改订单状态和时间
	 * @param orderNumber
	 * @param orderState
	 * @return
	 */
	public boolean modifyDele(String orderNumber, OrderState orderState,Timestamp orderTime) throws BizException;

}
